home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / GDIDIB.PAK / WINMAIN.C < prev   
C/C++ Source or Header  |  1997-05-06  |  3KB  |  91 lines

  1. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright (C) 1993 - 1995  Microsoft Corporation.  All Rights Reserved.
  7. //
  8. //  MODULE:   winmain.c
  9. //
  10. //  PURPOSE:   Calls initialization functions and processes the message loop
  11. //
  12. //
  13. //  PLATFORMS: Win95, NT
  14. //
  15. //  FUNCTIONS:
  16. //    WinMain() - calls initialization functions, processes message loop
  17. //
  18. //  COMMENTS:
  19. //
  20. //
  21.  
  22. #include <windows.h>            // required for all Windows applications
  23. #include "globals.h"            // prototypes specific to this application
  24.  
  25. //
  26. //  FUNCTION: WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
  27. //
  28. //  PURPOSE: calls initialization function, processes message loop
  29. //
  30. //  PARAMETERS:
  31. //
  32. //    hInstance - The handle to the instance of this application that
  33. //          is currently being executed.
  34. //
  35. //    hPrevInstance - This parameter is always NULL in Win32
  36. //          applications.
  37. //
  38. //    lpCmdLine - A pointer to a null terminated string specifying the
  39. //          command line of the application.
  40. //
  41. //    nCmdShow - Specifies how the main window is to be diplayed.
  42. //
  43. //  RETURN VALUE:
  44. //    If the function terminates before entering the message loop,
  45. //    return FALSE.
  46. //    Otherwise, return the WPARAM value sent by the WM_QUIT message.
  47. //
  48. //
  49. //  COMMENTS:
  50. //
  51. //    Windows recognizes this function by name as the initial entry point
  52. //    for the program.  This function calls the initialization routine
  53. //    It then executes a message retrieval and dispatch loop that is the
  54. //    top-level control structure for the remainder of execution.  The
  55. //    loop is terminated when a WM_QUIT  message is received, at which
  56. //    time this function exits the application instance by returning the
  57. //    value passed by PostQuitMessage().
  58. //
  59. //    If this function must abort before entering the message loop, it
  60. //    returns the conventional value NULL.
  61. //
  62.  
  63. #pragma argsused
  64. int WINAPI WinMain(HINSTANCE hInstance,
  65.                    HINSTANCE hPrevInstance, 
  66.                    LPSTR     lpCmdLine, 
  67.                    int       nCmdShow)
  68. {
  69.     MSG msg;
  70.     HANDLE hAccelTable;
  71.  
  72.     // Initialize application by setting up the main window.
  73.     if (!InitApplication(hInstance, nCmdShow))
  74.     {
  75.         return FALSE;           // Exits if unable to initialize
  76.     }
  77.  
  78.     hAccelTable = LoadAccelerators(hInstance, szAppName);
  79.  
  80.     // Acquire and dispatch messages until a WM_QUIT message is received.
  81.     while( GetMessage(&msg, NULL, 0, 0))
  82.     {
  83.         if (!TranslateAccelerator (msg.hwnd, hAccelTable, &msg))
  84.         {
  85.             TranslateMessage(&msg);  // Translates virtual key codes
  86.             DispatchMessage(&msg);   // Dispatches message to window
  87.         }
  88.     }
  89.     return msg.wParam;  // Returns the value from PostQuitMessage
  90. }
  91.